<?php
include_once ("databaseconnection.php");

$OldPassword=$_POST['OldPassword'];
$NewPassword=$_POST['NewPassword'];
$PasswordVar=$_POST['PasswordVar'];
 $_SESSION['successpri']="";
if($OldPassword!=""&&$NewPassword!="")
	{
	$Password=$_SESSION['password'];
	if($OldPassword==$Password)
	{
	$npw=$NewPassword;
	$npwlen=strlen($npw);
	$npwre=$npw;
	if($PasswordVar=="")
 {
 $_SESSION['errorveri']="Please Verify your new Password!";
 }
 if($PasswordVar!="")
 {
if($NewPassword!=$PasswordVar)
{
$_SESSION['errorveri']="Your verification is failed please try again!";
}

if($NewPassword==$PasswordVar)
{
$md5npass=md5($NewPassword);
$Log_Username=$_SESSION['username'];
date_default_timezone_set("Europe/Paris");
    $t_d=date("Y/m/d");
$sql=mysql_query("UPDATE user SET Password='$md5npass',Last_Updated_Date='$t_d' WHERE Login_Username='$Log_Username'");
if($sql)
  {
  $_SESSION['successpri']="succ";
}
if(!$sql)
  {
$_SESSION['error']="Sorry unable to change your password!";
}
 }
  }
  }
  if($OldPassword!=$Password)
	{
	$_SESSION['errorop']="Sorry you have entered wrong Old password please try again!";
	}
  }
  if($OldPassword==""||$NewPassword=="")
	{
	$_SESSION['error']="Please fill all!";
    }
 ?>
